import 'package:get/get.dart';

enum StarName {
  ziWeiMaj,
  tianJiMaj,
  taiYangMaj,
  wuQuMaj,
  tianTongMaj,
  lianZhenMaj,
  tianFuMaj, // 天府星
  taiYinMaj,
  tanLangMaj,
  juMenMaj,
  tianXiangMaj,
  tianLiangMaj,
  qiShaMaj,
  poJunMaj,
  zuoFuMin,
  youBiMin,
  wenChangMin,
  wenQuMin,
  luCunMin,
  tianMaMin,
  qingYangMin,
  tuoLuoMin,
  huoXingMin,
  lingXingMin,
  tianKuiMin,
  tianYueMin,
  diKongMin,
  diJieMin,
  tianKong,
  tianXing,
  tianYao,
  jieShen,
  yinSha,
  tianXi,
  tianGuan,
  tianFu, // 天福
  tianKu,
  tianXu,
  longChi,
  fengGe,
  hongLuan,
  guChen,
  guaSu,
  feiLian,
  poSui,
  taiFu,
  fengGao,
  tianWu,
  tianYue,
  sanTai,
  baZuo,
  engGuang,
  tianGui,
  tianCai,
  tianShou,
  jieKong,
  xunZhong,
  xunKong,
  kongWang,
  jieLu,
  yueDe,
  tianShang,
  tianShi,
  tianChu,
  changSheng,
  muYu,
  guanDai,
  linGuan,
  diWang,
  shuai,
  bing,
  si,
  mu,
  jue,
  tai,
  yang,
  boShi,
  liShi,
  qingLong,
  xiaoHao,
  jiangJun,
  zouShu,
  flyLian,
  xiShen,
  bingFu,
  daHao,
  fuBing,
  guanFu,
  suiJian,
  huiQi,
  sangMen,
  guanSuo,
  gwanFu,
  longDe,
  baiHu,
  tianDe,
  diaoKe,
  jiangXin,
  panAn,
  suiYi,
  xiiShen,
  huaGai,
  jieSha,
  zhaiSha,
  tianSha,
  zhiBei,
  xianChi,
  yueSha,
  wangShen,
  yunKui,
  yunYue,
  yunChang,
  yunQu,
  yunLuan,
  yunXi,
  yunLu,
  yunYang,
  yunTuo,
  yunMa,
  liuKui,
  liuYue,
  liuChang,
  liuQu,
  liuLuan,
  liuXi,
  liuLu,
  liuYang,
  liuTuo,
  liuMa,
  nianJie,
  yueKui,
  yueYue,
  yueChang,
  yueQu,
  yueLu,
  yueYang,
  yueTuo,
  yueMa,
  yueLuan,
  yueXi,
  riKui,
  riYue,
  riChang,
  riQu,
  riLu,
  riLuan,
  riXi,
  riYang,
  riTuo,
  riMa,
  shiKui,
  shiYue,
  shiChang,
  shiQu,
  shiLuan,
  shiXi,
  shiLu,
  shiYang,
  shiTuo,
  shiMa,
  suiPo,
  jieShaAdj,
}

extension StartNameEx on StarName {
  String get title {
    return toString().split('.').last.tr;
  }

  String get starKey {
    return toString().split('.').last;
  }
}

StarName getStarNameFrom(String str) {
  var isContainStr = false;
  for (int i = 0; i < StarName.values.length; i++) {
    final value = StarName.values[i];
    if (value.starKey == str) {
      isContainStr = true;
      break;
    }
  }
  if (isContainStr) {
    return StarName.values.firstWhere(
      (e) => e.starKey == str,
      orElse: () => throw ArgumentError('invalid palace name str'),
    );
  } else {
    return StarName.values.firstWhere(
      (e) => e.title == str,
      orElse: () => throw ArgumentError('invalid palace name string'),
    );
  }
}
